package com.txMsg.server.service.impl;

import com.txMsg.server.config.ExecutorConfig;
import com.txMsg.server.config.RabbitMQConfig;
import com.txMsg.server.entity.TxMsg;
import com.txMsg.server.service.TxMsgMQService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class TxMsgMQServiceImpl  implements TxMsgMQService {
    @Autowired
    AmqpTemplate amqpTemplate;
    @Override
    @Async(ExecutorConfig.myThreadPoolName)
    public void sendMsg(TxMsg txMsg) {
        amqpTemplate.convertAndSend(RabbitMQConfig.TXMSG_EXCHANGE,txMsg.getRoutingKey(),txMsg.getRoutingKeyData());
    }
}
